package com.young.common.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResultData<T> implements Serializable {

    private Integer code;
    private  String  msg;
    private       T data;

    public ResultData(Integer code, String msg) {
        this(code, msg, null);
    }

    private ResultData(ResultEnum result) {
        this(result.getCode(), result.getMessage(), null);
    }

    public static ResultData<?> of(@NotNull ResultEnum result) {
        return new ResultData<>(result);
    }

}
